Extract
generic,
defined in the R base-package
for the expected behavior.## S3 method for class 'otu_table,ANY,ANY,ANY':
[(x, i, j, ..., drop = TRUE)## S3 method for class 'sample_data,ANY,ANY,ANY':
[(x, i, j, ..., drop = TRUE)
## S3 method for class 'taxonomyTable,ANY,ANY,ANY':
[(x, i, j, ..., drop = TRUE)
## S3 method for class 'XStringSet,character,ANY,ANY':
[(x, i)
numeric
or character
vectors or empty (missing) or
NULL
. Numeric values are coerced to integer as by
as.integer
(and hence truncated towards zero).
Character vectors will be matched to the names
of the
object (or for matrices/arrays, the dimnames
):
see For [
-indexing only: i
, j
, ...
can be
logical vectors, indicating elements/slices to select. Such vectors
are recycled if necessary to match the corresponding extent.
i
, j
, ...
can also be negative integers,
indicating elements/slices to leave out of the selection.
When indexing arrays by [
a single argument i
can be a
matrix with as many columns as there are dimensions of x
; the
result is then a vector with elements corresponding to the sets of
indices in each row of i
.
An index value of NULL
is treated as if it were integer(0)
.
Extract
Extract
TRUE
the result is
coerced to the lowest possible dimension (see the examples). This
only works for extracting elements, not for the replacement. See
drop
for further details.drop
argument is set internally to FALSE
.
This helps avoid bugs during complicated subsetting with multiple components,
where it is necessary to be able to use a two dimensional indexing even
if one of those dimensions has only 1 rank.
Put another way, these phyloseq-defined extractions never collapse their result
into a vector. See the documentation of Extract
for
more information about the drop
argument.Extract
data(esophagus)
nrow(otu_table(esophagus))
nrow(otu_table(esophagus)[1:5, ])
Run the code above in your browser using DataLab